package com.mk.admin.service.impl;

import com.mk.admin.mapper.SymptomMapper;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.entity.SymptomEntity;
import com.mk.admin.model.vo.SymptomVo;
import com.mk.admin.service.SymptomService;
import com.mk.admin.util.DateTool;
import com.mk.admin.util.JSONCopy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SymptomServiceImpl implements SymptomService {
    @Autowired
    private SymptomMapper symptomMapper;

    @Override
    public ResultDto select(SymptomVo symptomVo) {
        SymptomEntity entity = JSONCopy.copy(symptomVo, SymptomEntity.class);
        return ResultDto.data(symptomMapper.count(entity), symptomMapper.select(entity));
    }

    @Override
    public ResultDto add(SymptomVo symptomVo) {
        SymptomEntity entity = JSONCopy.copy(symptomVo, SymptomEntity.class);
        entity.setCreateTime(DateTool.format());
        return ResultDto.data(symptomMapper.insert(entity));
    }

    @Override
    public ResultDto update(SymptomVo symptomVo) {
        SymptomEntity entity = JSONCopy.copy(symptomVo, SymptomEntity.class);
        return ResultDto.data(symptomMapper.updateById(entity));
    }

    @Override
    public ResultDto delete(int id) {
        return ResultDto.data(symptomMapper.deleteById(id));
    }

    @Override
    public ResultDto status(int id) {
        return ResultDto.data(symptomMapper.status(id));
    }


}
